<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>set与with的使用</title>
</head>
<body>
    <h1>set与with的使用</h1>

    <!-- 定义全局变量 -->
    {% set uname = 'bit' %}

    <p>用户名：{{uname}}</p>


    <!-- with 定义局部变量 -->
    {% with nick = '吕布' %}
        <p>昵称：{{nick}}</p>
    {% endwith %}

    {% with %}
        {% set age = 18%}
        <p>年龄：{{age}}</p>
    {% endwith %}


    <p>昵称：{{nick}}</p>
    <p>年龄：{{age}}</p>
</body>
</html>